﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Coolite.Ext;
using Coolite.Ext.Web;
using SubSonic;
using CXDB; 
public partial class User_ScoreModify : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Sub(object s, AjaxEventArgs e)
    {
        Query q = new Query(VwChengxindetail.Schema);
        q.AddWhere("chengxinid",ComboBox2.SelectedItem.Value);
        q.AddWhere("tradeid",ComboBox1.SelectedItem.Value);
        q.AddWhere("scores", SubSonic.Comparison.NotEquals, NumberField1.Value.ToString());
        q.AddWhere("status",1);
        q.SetSelectList("scores,companyid");
        IDataReader dr = q.ExecuteReader();
        while (dr.Read())
        {
            Query update = new Query(CxChengxin.Schema);
            update.AddWhere("companyid", dr[1].ToString());
            update.AddWhere("chengxinid", ComboBox2.SelectedItem.Value.ToString());
            update.AddWhere("scores", SubSonic.Comparison.NotEquals, NumberField1.Value.ToString());
            update.AddWhere("status", 1);
            update.AddUpdateSetting("scores", NumberField1.Value.ToString());
            update.Execute();
            CxCompanyBase cx = new CxCompanyBase("companyid", dr[1].ToString());
            if (NumberField1.Value.ToString() == "0")
            {
                cx.Scores = cx.Scores - 1;
            }
            else {
                cx.Scores = cx.Scores + 1;
            }
            cx.Save();
        }
        CxCompanyTradeModifyLog.Insert(ComboBox1.SelectedItem.Text.ToString(), int.Parse(NumberField1.Value.ToString()), DateTime.Now);
        ComboBox1.Reset();
        ComboBox2.Reset();
        Store1.DataBind();
        Err.Warning("批量修改成功！",MessageBox.Icon.INFO);
    }
 
}
